import java.awt.BorderLayout;

import javax.swing.ButtonGroup;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Dimension;
import javax.swing.JSlider;
import java.awt.Rectangle;
import javax.swing.JLabel;
import javax.swing.JButton;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import javax.swing.JRadioButton;

public class RateAGirlMain extends JFrame {
	public ButtonGroup jPrefButtonGroup = new ButtonGroup();

	private static final long serialVersionUID = 1L;
	private JPanel jContentPane = null;
	private JSlider jAppearanceSlider = null;
	private JLabel jLabel = null;
	private JLabel jLabel1 = null;
	private JSlider jIntelSlider = null;
	private JLabel jLabel2 = null;
	private JSlider jSexAppealSlider = null;
	private JLabel jLabel21 = null;
	private JSlider jMentalStableSlider = null;
	private JLabel jLabel3 = null;
	private JSlider jPersonalitySlider = null;
	private JLabel jLabel4 = null;
	private JSlider jFunFactorSlider = null;
	private JPanel jPanel = null;
	private JLabel jLabel5 = null;

	private JRadioButton jRadioButtonPref_Look = null;
	private JRadioButton jRadioButtonPref_Intel = null;
	private JRadioButton jRadioButtonPref_Enj = null;

	private JButton jCalculateButton = null;

	private JButton jResetButton = null;

	/**
	 * This is the default constructor
	 */
	public RateAGirlMain() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(356, 298);
		this.setContentPane(getJContentPane());
		this.setTitle("JFrame");
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jLabel4 = new JLabel();
			jLabel4.setBounds(new Rectangle(21, 217, 78, 15));
			jLabel4.setText("Fun Factor");
			jLabel3 = new JLabel();
			jLabel3.setBounds(new Rectangle(21, 180, 76, 15));
			jLabel3.setText("Personality");
			jLabel21 = new JLabel();
			jLabel21.setBounds(new Rectangle(21, 138, 100, 15));
			jLabel21.setText("Mental Stability");
			jLabel2 = new JLabel();
			jLabel2.setBounds(new Rectangle(21, 94, 81, 15));
			jLabel2.setText("Sex appeal");
			jLabel1 = new JLabel();
			jLabel1.setBounds(new Rectangle(21, 50, 80, 15));
			jLabel1.setText("Intelligence");
			jLabel = new JLabel();
			jLabel.setBounds(new Rectangle(21, 11, 82, 15));
			jLabel.setText("Appearance");
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(getJAppearanceSlider(), null);
			jContentPane.add(jLabel, null);
			jContentPane.add(jLabel1, null);
			jContentPane.add(getJIntelSlider(), null);
			jContentPane.add(jLabel2, null);
			jContentPane.add(getJSexAppealSlider(), null);
			jContentPane.add(jLabel21, null);
			jContentPane.add(getJMentalStableSlider(), null);
			jContentPane.add(jLabel3, null);
			jContentPane.add(getJPersonalitySlider(), null);
			jContentPane.add(jLabel4, null);
			jContentPane.add(getJFunFactorSlider(), null);
			jContentPane.add(getJPanel(), null);
			jContentPane.add(getJCalculateButton(), null);
			jContentPane.add(getJResetButton(), null);
			jPrefButtonGroup.add(jRadioButtonPref_Enj);
			jPrefButtonGroup.add(jRadioButtonPref_Look);
			jPrefButtonGroup.add(jRadioButtonPref_Intel);
		}
		return jContentPane;
	}

	/**
	 * This method initializes jAppearanceSlider
	 * 
	 * @return javax.swing.JSlider
	 */
	private JSlider getJAppearanceSlider() {
		if (jAppearanceSlider == null) {
			jAppearanceSlider = new JSlider();
			jAppearanceSlider.setBounds(new Rectangle(11, 27, 200, 16));
		}
		return jAppearanceSlider;
	}

	/**
	 * This method initializes jIntelSlider
	 * 
	 * @return javax.swing.JSlider
	 */
	private JSlider getJIntelSlider() {
		if (jIntelSlider == null) {
			jIntelSlider = new JSlider();
			jIntelSlider.setBounds(new Rectangle(11, 65, 200, 16));
		}
		return jIntelSlider;
	}

	/**
	 * This method initializes jSexAppealSlider
	 * 
	 * @return javax.swing.JSlider
	 */
	private JSlider getJSexAppealSlider() {
		if (jSexAppealSlider == null) {
			jSexAppealSlider = new JSlider();
			jSexAppealSlider.setBounds(new Rectangle(11, 109, 200, 16));
		}
		return jSexAppealSlider;
	}

	/**
	 * This method initializes jMentalStableSlider
	 * 
	 * @return javax.swing.JSlider
	 */
	private JSlider getJMentalStableSlider() {
		if (jMentalStableSlider == null) {
			jMentalStableSlider = new JSlider();
			jMentalStableSlider.setBounds(new Rectangle(11, 153, 200, 16));
		}
		return jMentalStableSlider;
	}

	/**
	 * This method initializes jPersonalitySlider
	 * 
	 * @return javax.swing.JSlider
	 */
	private JSlider getJPersonalitySlider() {
		if (jPersonalitySlider == null) {
			jPersonalitySlider = new JSlider();
			jPersonalitySlider.setBounds(new Rectangle(11, 196, 200, 16));
		}
		return jPersonalitySlider;
	}

	/**
	 * This method initializes jFunFactorSlider
	 * 
	 * @return javax.swing.JSlider
	 */
	private JSlider getJFunFactorSlider() {
		if (jFunFactorSlider == null) {
			jFunFactorSlider = new JSlider();
			jFunFactorSlider.setBounds(new Rectangle(11, 236, 200, 16));
		}
		return jFunFactorSlider;
	}

	/**
	 * This method initializes jPanel
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJPanel() {
		if (jPanel == null) {
			jLabel5 = new JLabel();
			jLabel5.setText("Prefrences");
			jLabel5.setBounds(new Rectangle(4, 4, 76, 15));
			jPanel = new JPanel();
			jPanel.setLayout(null);
			jPanel.setBounds(new Rectangle(220, 4, 127, 115));
			jPanel.add(jLabel5, null);
			jPanel.add(getJRadioButtonPref_Look(), null);
			jPanel.add(getJRadioButtonPref_Intel(), null);
			jPanel.add(getJRadioButtonPref_Enj(), null);
		}
		return jPanel;
	}

	/**
	 * This method initializes jRadioButtonPref_Look
	 * 
	 * @return javax.swing.JRadioButton
	 */
	private JRadioButton getJRadioButtonPref_Look() {
		if (jRadioButtonPref_Look == null) {
			jRadioButtonPref_Look = new JRadioButton();
			jRadioButtonPref_Look.setBounds(new Rectangle(9, 24, 97, 21));
			jRadioButtonPref_Look.setText("Looks");
		}
		return jRadioButtonPref_Look;
	}

	/**
	 * This method initializes jRadioButtonPref_Intel
	 * 
	 * @return javax.swing.JRadioButton
	 */
	private JRadioButton getJRadioButtonPref_Intel() {
		if (jRadioButtonPref_Intel == null) {
			jRadioButtonPref_Intel = new JRadioButton();
			jRadioButtonPref_Intel.setBounds(new Rectangle(9, 51, 110, 21));
			jRadioButtonPref_Intel.setText("Intelligence");

		}
		return jRadioButtonPref_Intel;
	}

	/**
	 * This method initializes jRadioButtonPref_Enj
	 * 
	 * @return javax.swing.JRadioButton
	 */
	private JRadioButton getJRadioButtonPref_Enj() {
		if (jRadioButtonPref_Enj == null) {
			jRadioButtonPref_Enj = new JRadioButton();
			jRadioButtonPref_Enj.setBounds(new Rectangle(9, 77, 112, 21));
			jRadioButtonPref_Enj.setText("Enjoyment");
		}
		return jRadioButtonPref_Enj;
	}

	/**
	 * This method initializes jCalculateButton
	 * 
	 * @return javax.swing.JButton
	 */
	private JButton getJCalculateButton() {
		if (jCalculateButton == null) {
			jCalculateButton = new JButton();
			jCalculateButton.setBounds(new Rectangle(222, 225, 121, 22));
			jCalculateButton.setText("Calculate");
			jCalculateButton
					.addActionListener(new java.awt.event.ActionListener() {
						public void actionPerformed(java.awt.event.ActionEvent e) {
							displayCalculations();
						}
					});
		}
		return jCalculateButton;
	}

	/**
	 * Returns appearance from the slider
	 * 
	 * @return int appearance
	 */
	private int getApppearance() {
		return jAppearanceSlider.getValue();
	}

	/**
	 * Returns intelligence from the slider
	 * 
	 * @return int intelligence
	 */
	private int getIntelligence() {
		return jIntelSlider.getValue();
	}

	/**
	 * Returns sexAppeal from the slider
	 * 
	 * @return int sexAppeal
	 */
	private int getSexAppeal() {
		return jSexAppealSlider.getValue();
	}

	/**
	 * Returns mental stability from the slider
	 * 
	 * @return int mentalStable
	 */
	private int getMentalStable() {
		return jMentalStableSlider.getValue();
	}

	/**
	 * returns personality from the slider
	 * 
	 * @return int personality
	 */
	private int getPersonality() {
		return jPersonalitySlider.getValue();
	}

	/**
	 * returns fun factor from the slider
	 * 
	 * @return int funFactor
	 */
	private int getFunFactor() {
		return jFunFactorSlider.getValue();
	}

	/**
	 * Returns true if they prefer Looks
	 * 
	 * @return boolean lookPref
	 */
	private boolean isLookPref() {
		if (jRadioButtonPref_Look.isSelected()) {
			return true;
		} else {
			return false;
		}
	}

	/**
	 * returns true if they prefer Intel
	 * 
	 * @return boolean intelPref
	 */
	private boolean isIntelPref() {
		if (jRadioButtonPref_Intel.isSelected()) {
			return true;
		} else {
			return false;
		}
	}

	/**
	 * returns true if they prefer Enjoyablity
	 * 
	 * @return boolean enjoyPref
	 */
	private boolean isEnjoyPref() {
		if (jRadioButtonPref_Enj.isSelected()) {
			return true;
		} else {
			return false;
		}
	}

	private void displayCalculations() {
		JOptionPane.showMessageDialog(this, "Their rating is : "+calculate());
	}

	private int calculate() {
		int appearance = getApppearance();
		int intel = getIntelligence();
		int sexApeal = getSexAppeal();
		int mentalStable = getMentalStable();
		int personality = getPersonality();
		int funFactor = getFunFactor();
		
		if (isLookPref()==true){
			return ((appearance * 2) + (sexApeal * 2) + intel + mentalStable + personality + funFactor ) / 8;
		}
		else if (isIntelPref()==true){
			return ((intel * 2)+(mentalStable * 2)+appearance+sexApeal+personality+funFactor )/8;
		}
		else if (isEnjoyPref()==true){
			return ((funFactor * 2)+(personality * 2)+appearance+sexApeal+intel+mentalStable)/8;
		}
		else { 
			return 0;
		}
	}
	public void doReset(){
		jAppearanceSlider.setValue(50);
		jFunFactorSlider.setValue(50);
		jIntelSlider.setValue(50);
		jMentalStableSlider.setValue(50);
		jPersonalitySlider.setValue(50);
		jSexAppealSlider.setValue(50);
	}

	/**
	 * This method initializes jResetButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJResetButton() {
		if (jResetButton == null) {
			jResetButton = new JButton();
			jResetButton.setBounds(new Rectangle(222, 198, 91, 25));
			jResetButton.setText("Reset");
			jResetButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					doReset();
					System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
				}

			});
		}
		return jResetButton;
	}

} // @jve:decl-index=0:visual-constraint="10,10"
